package com.ccq.farm.common.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

/**
 * Created by HiWin10 on 2018-06-23.
 * @author ccq
 * @create 2018年6月23日 17:38:08
 */
@Configuration
@PropertySource(value = "classpath:druid.properties")
public class DruidConfiguration {

    @Bean(destroyMethod = "close" ,initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource")
    @Primary
    public DataSource druidDataSource(){
        return new DruidDataSource();
    }
}
